$OpenBSD: patch-lib_Makefile,v 1.6 2016/08/31 22:12:43 naddy Exp $
--- lib/Makefile.orig	Sun Jun 26 19:15:09 2016
+++ lib/Makefile	Wed Aug 31 16:32:56 2016
@@ -52,6 +52,9 @@ LIBOBJECTS_X = \
   util/token.o \
   util/vasprintf.o \
 
+SHLIBOBJECTS = $(patsubst %.o, %.lo, $(LIBOBJECTS))
+SHLIBOBJECTS_X = $(patsubst %.o, %.lo, $(LIBOBJECTS_X))
+
 MANUALS3 = libnetpbm
 MANUALS5 = pbm pgm ppm pnm pam
 
@@ -88,13 +91,16 @@ extra_staticlib: $(EXTRA_STATICLIB)
 # type, but request a static library in addition.
 #----------------------------------------------------------------------------
 
-$(LIBOBJECTS): CFLAGS_TARGET=$(CFLAGS_SHLIB)
+$(SHLIBOBJECTS): CFLAGS_TARGET=$(CFLAGS_SHLIB)
 
 libpbm3.o: CFLAGS_TARGET+=$(CFLAGS_SSE)
 
 $(LIBOBJECTS): %.o: %.c importinc
 	$(CC) -c $(INCLUDES) $(CFLAGS_ALL) -o $@ $<
 
+$(SHLIBOBJECTS): %.lo: %.c importinc
+	$(CC) -c $(INCLUDES) $(CFLAGS_ALL) -o $@ $<
+
 MAJ = 11
 MIN = $(NETPBM_MINOR_RELEASE)
 
@@ -119,7 +125,7 @@ endif
 
 ifeq ($(NETPBMLIBTYPE),unixshared)
 # The libxxx.so link is needed to link the executables.
-libnetpbm.$(NETPBMLIBSUFFIX): $(SONAME)
+libnetpbm.$(NETPBMLIBSUFFIX): libnetpbm.$(NETPBMLIBSUFFIX).$(LIBnetpbm_VERSION)
 	rm -f $@
 	$(SYMLINK) $< $@
 # The $(SONAME) link is needed only to test the programs without
@@ -128,8 +134,8 @@ libnetpbm.$(NETPBMLIBSUFFIX): $(SONAME)
 $(SONAME): libnetpbm.$(NETPBMLIBSUFFIX).$(MAJ).$(MIN)
 	rm -f $@
 	$(SYMLINK) $< $@
-libnetpbm.$(NETPBMLIBSUFFIX).$(MAJ).$(MIN): $(LIBOBJECTS) $(LIBOBJECTS_X)
-	$(LD) $(LDSHLIB) -o $@ $(LIBOBJECTS) $(LIBOBJECTS_X) \
+libnetpbm.$(NETPBMLIBSUFFIX).$(LIBnetpbm_VERSION): $(SHLIBOBJECTS) $(SHLIBOBJECTS_X)
+	$(LD) $(LDSHLIB) -o $@ $(SHLIBOBJECTS) $(SHLIBOBJECTS_X) \
           $(SHLIB_CLIB) -lm $(LADD)
 endif
 
@@ -205,25 +211,21 @@ standardppmdfont.c: standard.ppmdfont
 compile.h:
 	$(SRCDIR)/buildtools/stamp-date >$@ || rm $@
 
-$(LIBOBJECTS_X): FORCE
+$(LIBOBJECTS_X) $(SHLIBOBJECTS_X): FORCE
 	@if [ ! -d $(dir $@) ] ; then mkdir $(dir $@) ; fi
 	$(MAKE) -C $(dir $@) -f $(SRCDIR)/$(SUBDIR)/$(dir $@)Makefile \
 		SRCDIR=$(SRCDIR) BUILDDIR=$(BUILDDIR) $(notdir $@) 
 
-libpm.o: compile.h
+libpm.o libpm.lo: compile.h
 
 # Install a shared library
 #
 .PHONY: install.lib
 ifeq ($(NETPBMLIBTYPE),unixshared)
 # install a Unix-style shared library
-install.lib: $(PKGDIR)/lib $(PKGDIR)/link
-	cd $(PKGDIR)/lib ; rm -f libnetpbm.$(NETPBMLIBSUFFIX).$(MAJ).*
+install.lib: $(PKGDIR)/lib
 	$(INSTALL) -c -m $(INSTALL_PERM_LIBD) \
-	  libnetpbm.$(NETPBMLIBSUFFIX).$(MAJ).$(MIN)  $(PKGDIR)/lib/
-	cd $(PKGDIR)/lib/ ; \
-          rm -f libnetpbm.$(NETPBMLIBSUFFIX).$(MAJ); \
-          $(SYMLINK) libnetpbm.$(NETPBMLIBSUFFIX).$(MAJ).$(MIN) $(SONAME)
+	  libnetpbm.$(NETPBMLIBSUFFIX).$(LIBnetpbm_VERSION)  $(PKGDIR)/lib/
 endif
 ifeq ($(NETPBMLIBTYPE),dll)
 #install a Windows DLL shared library
@@ -259,9 +261,9 @@ $(INTERFACE_HEADERS:%=%_installhdr): $(PKGDIR)/include
 	  $(SRCDIR)/lib/$(@:%_installhdr=%) $(PKGDIR)/include/netpbm/
 
 .PHONY: install.staticlib
-install.staticlib: $(PKGDIR)/link
+install.staticlib: $(PKGDIR)/lib
 	$(INSTALL) -c -m $(INSTALL_PERM_LIBS) libnetpbm.$(STATICLIBSUFFIX) \
-	  $(PKGDIR)/link
+	  $(PKGDIR)/lib
 
 # Install a shared library stub -- the ".so" file used at link time to
 # prepare a program for dynamically linking a library at run time 
